package com.xiechanglei.work;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;

/**
 * @author decayparidise
 *	项目部署小程序
 */
public class Deploy {

	public static Map<String, String> pros = new HashMap<String, String>();
	public static void main(String[] args) throws IOException {
		deploy("项目名称", "项目地址");	
//		deploy("houde", "D:\\厚德财富\\p2pv1.0\\WebRoot");
		deploy("chengqidai", "D:\\网贷平台\\p2p\\WebRoot");
		
		
		
		
		
		
		
		
		
		
		
		
		
		File file = new File("E:/apache-tomcat-6.0.20/conf/server.xml");
		BufferedReader reader = new BufferedReader(new FileReader("E:/apache-tomcat-6.0.20/conf/before.txt"));
		PrintWriter pw = new PrintWriter(file);
		String readline = null;
		while((readline = reader.readLine())!=null){
			pw.println(readline);
		}
		reader.close();
		Set<Entry<String, String>> entrySet = pros.entrySet();
		for (Entry<String, String> entry : entrySet) {
			pw.println("		<Context path=\"/"+entry.getKey()+"\" docBase=\""+entry.getValue()+"\" reloadable=\"true\"></Context>");
		}
		pw.println("</Host>");
		pw.println("</Engine>");
		pw.println("</Service>");
		pw.println("</Server>");
		pw.flush();
		pw.close();
	}
	public static void deploy(String path,String docBase){
		pros.put(path, docBase);
	}
}
